<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>对象解构</title>
</head>

<body>
    <script>
        const Tom = {
            name: 'Tom Jones',
            age: 25,
            family: {
                mother: 'Norah Jones',
                father: 'Richard Jones',
                brother: 'Howard Jones'
            },
        }
        /*
        const name = Tom
        */
        const {name, age} = Tom
        //如果father预先定义,可以重新起名为f以示区分
        const father = "Dad"
        //给sister设置默认值
        const {mother, father: f, brother,sister = "have no sister"} = Tom.family
        console.log(mother)
        console.log(f)
        console.log(brother)
    </script>
</body>

</html>